package com.azt.front.servlet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.IOException;

/**
 * Created by zouheyuan on 2017/3/15.
 */
public class PAServerListener implements ServletContextListener {

    public static Logger logger = LoggerFactory.getLogger("paInfo");

    Server server = null;

    @Override
    public void contextInitialized(ServletContextEvent sce) {//启动时
        logger.info("进入监听方法开启socket");
        if (null == server) {
            logger.info("server为null时启动");
            server = new Server();
            server.start();
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {//销毁时
        logger.info("进入监听方法关闭socket");
        if (server != null) {
            server.stopServer();
        }
    }
}
